//注册
const register = 'insert into user(user_name,user_pass,code) values(?,?,?)';
//登录
const login = 'select user_id from user where user_name=? and user_pass=?';
//用户名
const sel_name = 'select user_name from user where user_id=?';
//查看用户信息
const selUser = 'select * from user where user_id=?';
//修改用户信息
const updateUser = 'update user set user_header=?,nickname=?,sex=?,birthday=?,user_name=? where user_id=?';
//忘记密码
const forgetPass = 'update user set user_pass=? where user_name=?';
const code = 'select code from user where user_id=?';

//首页
const Classify = 'select * from product where product_variety = ?';
//搜索商品
const search = "select * from product where product_name like ?";
//积分商城
const selIntegralProduct = 'select * from integral_product';
//积分商品
const selIntegralSingle = 'select * from integral_product where integral_id = ?';
// 积分商品评价
const selIntegralEvaluate = 'select * from integral_evaluate where integral_id =?'

//同城
const Local = 'select * from local';
//同城分类
const LocalClassify = 'select * from local where local_classify = ?';
//查看商品评价
const evaluate = 'select * from evaluate where product_id = ?';
//添加商品评价
const addEvaluate = 'insert into evaluate(evaluate_text,user_name,user_header,user_score,product_id,order_id,evaluate_time) values(?,?,?,?,?,?,?)';

//添加购物车
const addCart = 'insert into cart(store_name,user_id,cart_totalPrice,product) values(?,?,?,?)';
//购物车信息
const Cart = 'select * from cart where user_id=?';
//查询商店
const store = 'select * from store'
// 删除购物车商品
const delGoods = 'delete from cart where cart_id in(?)'

//添加确认订单
const Ensure = 'insert into ensureIndent(store_name,user_id,totalPrice,product) values(?,?,?,?)';
//查看确认订单
const selEnsure = 'select * from ensureIndent where user_id=?';
//删除确认订单
const delEnsure = 'delete from ensureIndent where ensure_id=?';


//商品信息
const selProduct = 'select * from product where product_id =?';
//验证用户
const verify = 'select * from user where user_id = ? and user_pass=?';
//支付
const pay = 'update user set money=money-?,integral=integral+? where user_id=?';
// 积分支付
const payIntegral = 'update user set integral=integral-? where user_id=?'

//充值账户
const addMoney = 'update user set money=money+? where user_id =?';
//查询账户
const SelMoney = 'select * from user where user_id = ?';
//查询账单
const selBill = 'select * from bill where user_id=?'
//添加订单
const addBill = 'insert into bill(bill_type,consume_money,balance,consume_time,user_id) values(?,?,?,?,?)';
//添加积分商城订单
const addBillIntegral = 'insert into integral_bill(bill_type,consume_money,balance,consume_time,user_id) values(?,?,?,?,?)';

//积分订单
const SelIndentIntegral = 'select * from integral_indent where user_id=?';
// 删除积分商城订单
const delIndentIntegral = 'delete from integral_indent where indent_id in(?)'

//全部订单
const SelIndent = 'select * from indent where user_id=?';
//添加订单
const addIndent = 'insert into indent(order_time,store_name,order_status,total_price,freight,user_id,product_id,order_evaluate,product,address_id,address_name,address,address_phone,boss_name,boss_phone) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)';
// 添加积分商城订单
const addIntegralIndent = 'insert into integral_indent(order_time,store_name,order_status,total_price,freight,user_id,integral_id,order_evaluate,product,address_id,address_name,address,address_phone,boss_name,boss_phone) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)';
//查询需要付款的订单(有商店)
const SelSingleIndent = 'select order_id from indent where user_id=? and order_time=? and store_name=?'
//查询需要付款的订单(没商店)
const SelSingleIndents = 'select order_id from indent where user_id=? and order_time=?'
// 查询需要付款的积分订单(有商店)
const SelSingleIntegral = 'select indent_id from integral_indent where user_id=? and order_time=? and store_name=?'
// 查询需要付款的积分订单(没商店)
const SelSingleIntegrals = 'select indent_id from integral_indent where user_id=? and order_time=?'

//修改订单状态
const indentStatus = 'update indent set order_status=? where order_id in(?)';
//修改积分商城订单状态
const integralStatus = 'update integral_indent set order_status=? where indent_id in(?)';
//删除订单
const delOrder = 'delete from indent where order_id=?';



//添加地址
const addAddress = 'insert into address(consignee,area,street,contact_phone,comment,user_id,default_address) values(?,?,?,?,?,?,?)';
//重置默认地址
const resetAddress = 'update address set default_address=? where user_id=?';
//设置默认地址
const defaultAddress = 'update address set default_address=? where address_id=?';
//修改地址
const updateAddress = 'update address set consignee=?,area=?,street=?,contact_phone=?,comment=?,user_id=?,default_address=? where address_id=?';
//查询地址
const SelAddress = 'select * from address where user_id=?';
//删除地址
const delAddress = 'delete from address where address_id=?';
// 通过地址ID查询地址
const getAddress = 'select * from address where address_id=?';

//添加收藏
const addCollect = 'insert into collect(product_id,commodity,commodity_img,introduce,original_price,current_price,user_id) values(?,?,?,?,?,?,?)';
//查询收藏
const SelCollect = 'select * from collect where user_id=?';
//删除收藏
const delCollect = 'delete from collect where product_id=?';

//添加浏览记录
const addBrowsing = 'insert into browsing(product_id,commodity,commodity_img,introduce,original_price,current_price,user_id) values(?,?,?,?,?,?,?)';
//查询浏览记录
const SelBrowsing = 'select * from browsing where user_id=?';
//删除浏览记录
const delBrowsing = 'delete from browsing where browsing_id=?';
//我的消息
const news = 'select * from message where user_id=?';
//查看消息
const selNews = 'update message set message_status="已查看" where message_id=?';
//删除消息
const delNews = 'delete from message where message_id=?';
//意见反馈
const feedback = 'insert into feedback(opinion,user_id) values(?,?)';

module.exports = {
  //用户
  register,
  login,
  sel_name,
  selUser,
  updateUser,
  forgetPass,
  code,
  //首页
  Classify,
  search,
  //积分商城
  selIntegralProduct,
  selIntegralSingle,
  selIntegralEvaluate,
  SelIndentIntegral,
  delIndentIntegral,
  //同城
  Local,
  LocalClassify,
  //购物车
  store,
  Cart,
  addCart,
  selProduct,
  getAddress,
  delGoods,
  //确认订单
  Ensure,
  selEnsure,
  delEnsure,
  //评价
  evaluate,
  addEvaluate,
  //账户
  SelMoney,
  addMoney,
  verify,
  pay,
  payIntegral,
  //账单
  addBill,
  selBill,
  addBillIntegral,
  //订单
  addIndent,
  addIntegralIndent,
  SelIndent,
  SelSingleIndent,
  SelSingleIndents,
  SelSingleIntegral,
  SelSingleIntegrals,
  indentStatus,
  integralStatus,
  delOrder,
  //地址
  addAddress,
  resetAddress,
  defaultAddress,
  updateAddress,
  SelAddress,
  delAddress,
  //收藏
  addCollect,
  SelCollect,
  delCollect,
  //浏览记录
  addBrowsing,
  SelBrowsing,
  delBrowsing,
  //我的消息
  news,
  selNews,
  delNews,
  //意见反馈
  feedback,
}
